
#include "../../Command.h"

#include "../../engine.h"

#include "../../User.h"

#include "../../NLogic/Static.h"
#include "../../NLogic/Battle.h"

namespace ProjectZ { namespace NCommand {

void Command::CS_PK_REBIRTH(User * pUser, ::Network::Packet * pPacket)
{
	STRESSLOG("%s", __FUNCTION__);

	NLogic::Space * pSpace = pUser->GetSpace();
	if( NULL == pSpace )
	{
		NLogic::NFunction::SendExceptionNoSpace(pUser);
		DEBUGLOG("%s %d userseq[%d] Space is NULL", __FUNCTION__, __LINE__, pUser->GetUserSeq());
		return;
	}

	PREPARE_PACKET;

	uint32_t userseq;

	* pPacket >> userseq;

	::Network::Packet * pNoti = ::Network::GETPACKETPOOL()->SEND_NEW();
	*pNoti << userseq;
	pNoti->MakePacket(CMD_SN_PK_REBIRTH);



	pSpace->SendAll(pNoti);

	NLogic::Battle * pBattle = pSpace->FindBattle(userseq);
	if( NULL == pBattle )
	{
		DEBUGLOG("%s %d userseq[%d] User is NULL", __FUNCTION__, __LINE__, userseq);
		return;
	}

	pBattle->GetData().HP = pBattle->GetData().HP_MAX;

	pSpace->GetData()._aliveUserCount++;
}

} /*NCommand*/ } /*ProjectZ*/

